<template>
  <AModal okText="确定" cancelText="取消" @cancel="close" @ok="ok" title="重命名" :visible="visible">
    <a-input v-model="value"/>
  </AModal>
</template>
<script>
export default {
  name: 'ViewNameEditor',
  data() {
    return {
      visible: false,
      value: undefined,
      view: {
        viewName: undefined
      }
    };
  },
  methods: {
    edit(view) {
      this.view = view;
      this.value = this.view.viewName;
      this.open();
    },
    open() {
      this.visible = true;
    },
    ok() {
      if (!this.value) {
        this.$message.error('请输入视图名称');
        return;
      }
      this.view.viewName = this.value;
      this.close();
    },
    close() {
      this.visible = false;
    },
  }
};
</script>